﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MpSoft.Library.DAO.Categorys;
using MpSoft.Library.DTO;
using MpSoft.Basic.Configuration;

namespace MpSoft.Library.BUSS.Categories
{
    #region  CategoryLanguage
    
    public class CategoryLanguageBUSS
    {
        private const string CATEGORYLANGUAGE_ALL_KEY = "Mp.categorylanguage.all-{0}";
        private const string CATEGORYLANGUAGE_BY_ID_KEY = "Mp.categorylanguage.id-{0}";
        
        private static void CategoryLanguageRemoveCache()
        {
             MpCache.RemoveByPattern(CATEGORYLANGUAGE_ALL_KEY);
             MpCache.RemoveByPattern(CATEGORYLANGUAGE_BY_ID_KEY);
        }
        
        public static int CategoryLanguage_Add(CategoryLanguage obj)
        {
            var result = CategoryLanguageDAO.CategoryLanguage_Add(obj);
            return result;
        }
        public static int CategoryLanguage_Update(CategoryLanguage obj)
        {
            var result = CategoryLanguageDAO.CategoryLanguage_Update(obj);
            return result;
        }

        public static int CategoryLanguage_Delete(int CLID)
        {
            var result = CategoryLanguageDAO.CategoryLanguage_Delete(CLID);
            return result;
        }

        public static CategoryLanguage CategoryLanguage_ByID(int CLID)
        {
            var list = CategoryLanguage_Select(CLID, -1, null);
            if (list != null)
                return list.FirstOrDefault();
            return null;
        }

        public static CategoryLanguage CategoryLanguage_ByID(int CategoryID, string LanguageCode)
        {
            var list = CategoryLanguage_Select(-1, CategoryID, LanguageCode);
            if (list != null)
                return list.FirstOrDefault();
            return null;
        }

        public static List<CategoryLanguage> CategoryLanguage_Select(int CLID, int CategoryID, string LanguageCode)
        {
            return CategoryLanguageDAO.CategoryLanguage_Select(CLID, CategoryID, LanguageCode);
        }

    }
    
    #endregion
}

